import java.util.ArrayList;
import java.util.List;

public class Test {
    private static void func(int i) {
        System.out.println("func():"+i);
    }
    public static void main(String[] args) {
       int[] arr = {1,2,3};
        List<List<Integer>> ret = subsets(arr);
        System.out.println(ret);
    }
    static List<List<Integer>> ret;
    static List<Integer> path ;
    public static List<List<Integer>> subsets(int[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        dfs(nums,0);
        return ret;
    }
    public static void dfs(int[] nums,int i) {
        if(i == nums.length) {
            ret.add(new ArrayList<>(path));
            return;
        }
        //1.不选
        dfs(nums,i+1);
        //2.选
        path.add(nums[i]);
        dfs(nums,i+1);
        //选了就要回溯
        if(path.size() != 0) {
            path.remove(path.size()-1);
        }
    }
}
